Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experimental] Code block/editor optimizations #132

Merged
merged 15 commits into from
Jun 14, 2022
8 changes: 8 additions & 0 deletions demo/docs/intro.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ OpenAPI plugin for generating API reference docs in Docusaurus v2.

[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/HEAD/LICENSE) [![npm latest package](https://img.shields.io/npm/v/docusaurus-plugin-openapi-docs/latest.svg)](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [![npm downloads](https://img.shields.io/npm/dm/docusaurus-plugin-openapi-docs.svg)](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs) [![npm canary package](https://img.shields.io/npm/v/docusaurus-plugin-openapi-docs/canary.svg)](https://www.npmjs.com/package/docusaurus-plugin-openapi-docs)


<iframe
src="https://ghbtns.com/github-btn.html?user=PaloAltoNetworks&amp;repo=docusaurus-openapi-docs&amp;type=star&amp;count=true&amp;size=large"
width={160}
height={30}
title="GitHub Stars"
/>

</div>

---
Expand Down
2 changes: 1 addition & 1 deletion demo/docs/petstore/add-a-new-pet-to-the-store.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: add-a-new-pet-to-the-store
sidebar_label: Add a new pet to the store
hide_title: true
hide_table_of_contents: true
api: {"tags":["Pets"],"description":"Add new pet to the store inventory.","operationId":"addPet","responses":{"405":{"description":"Invalid input"}},"security":[{"petstore_auth":["write:pets","read:pets"]}],"x-codeSamples":[{"lang":"C#","source":"PetStore.v1.Pet pet = new PetStore.v1.Pet();\npet.setApiKey(\"your api key\");\npet.petType = PetStore.v1.Pet.TYPE_DOG;\npet.name = \"Rex\";\n// set other fields\nPetStoreResponse response = pet.create();\nif (response.statusCode == HttpStatusCode.Created)\n{\n // Successfully created\n}\nelse\n{\n // Something wrong -- check response for errors\n Console.WriteLine(response.getRawResponse());\n}\n"},{"lang":"PHP","source":"$form = new \\PetStore\\Entities\\Pet();\n$form->setPetType(\"Dog\");\n$form->setName(\"Rex\");\n// set other fields\ntry {\n $pet = $client->pets()->create($form);\n} catch (UnprocessableEntityException $e) {\n var_dump($e->getErrors());\n}\n"}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"description":"My Pet","title":"Pettie"},{"type":"object","required":["name","photoUrls"],"discriminator":{"propertyName":"petType","mapping":{"cat":"#/components/schemas/Cat","dog":"#/components/schemas/Dog","bee":"#/components/schemas/HoneyBee"}},"properties":{"id":{"externalDocs":{"description":"Find more info here","url":"https://example.com"},"description":"Pet ID","allOf":[{"type":"integer","format":"int64","readOnly":true}]},"category":{"description":"Categories this pet belongs to","allOf":[{"type":"object","properties":{"id":{"description":"Category ID","allOf":[{"type":"integer","format":"int64","readOnly":true}]},"name":{"description":"Category name","type":"string","minLength":1},"sub":{"description":"Test Sub Category","type":"object","properties":{"prop1":{"type":"string","description":"Dumb Property"}}}},"xml":{"name":"Category"}}]},"name":{"description":"The name given to a pet","type":"string","example":"Guru"},"photoUrls":{"description":"The list of URL to a cute photos featuring pet","type":"array","maxItems":20,"xml":{"name":"photoUrl","wrapped":true},"items":{"type":"string","format":"url"}},"friend":{"allOf":[{"$ref":"#/components/schemas/Pet"}]},"tags":{"description":"Tags attached to the pet","type":"array","minItems":1,"xml":{"name":"tag","wrapped":true},"items":{"type":"object","properties":{"id":{"description":"Tag ID","allOf":[{"type":"integer","format":"int64","readOnly":true}]},"name":{"description":"Tag name","type":"string","minLength":1}},"xml":{"name":"Tag"}}},"status":{"type":"string","description":"Pet status in the store","enum":["available","pending","sold"]},"petType":{"description":"Type of a pet","type":"string"}},"xml":{"name":"Pet"}}]}},"application/xml":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"hooray"}}}}},"description":"Pet object that needs to be added to the store","required":true},"method":"post","path":"/pet","servers":[{"url":"//petstore.swagger.io/v2","description":"Default server"},{"url":"//petstore.swagger.io/sandbox","description":"Sandbox server"}],"securitySchemes":{"petstore_auth":{"description":"Get access to data while protecting your account credentials.\nOAuth2 is also a safer and more secure way to give you access.\n","type":"oauth2","flows":{"implicit":{"authorizationUrl":"http://petstore.swagger.io/api/oauth/dialog","scopes":{"write:pets":"modify pets in your account","read:pets":"read your pets"}}}},"api_key":{"description":"For this sample, you can use the api key `special-key` to test the authorization filters.\n","type":"apiKey","name":"api_key","in":"header"}},"jsonRequestBodyExample":{"id":{},"category":{"id":{},"name":"string","sub":{"prop1":"string"}},"name":"Guru","photoUrls":["string"],"friend":{},"tags":[{"id":{},"name":"string"}],"status":"available","petType":"string"},"info":{"description":"This is a sample server Petstore server.\nYou can find out more about Swagger at\n[http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\nFor this sample, you can use the api key `special-key` to test the authorization filters.\n\n## Introduction\nThis API is documented in **OpenAPI format** and is based on\n[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.\nIt was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)\ntool and [ReDoc](https://github.com/Redocly/redoc) documentation. In addition to standard\nOpenAPI syntax we use a few [vendor extensions](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md).\n\n## OpenAPI Specification\nThis API is documented in **OpenAPI format** and is based on\n[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.\nIt was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)\ntool and [ReDoc](https://github.com/Redocly/redoc) documentation. In addition to standard\nOpenAPI syntax we use a few [vendor extensions](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md).\n\n## Cross-Origin Resource Sharing\nThis API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/).\nAnd that allows cross-domain communication from the browser.\nAll responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.\n\n## Authentication\n\nPetstore offers two forms of authentication:\n - API Key\n - OAuth2\nOAuth2 - an open protocol to allow secure authorization in a simple\nand standard method from web, mobile and desktop applications.\n","version":"2.0.0","title":"Swagger Petstore YAML","termsOfService":"http://swagger.io/terms/","contact":{"name":"API Support","email":"apiteam@swagger.io","url":"https://github.com/Redocly/redoc"},"x-logo":{"url":"https://redocly.github.io/redoc/petstore-logo.png","altText":"Petstore logo"},"license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},"postman":{"name":"Add a new pet to the store","description":{"content":"Add new pet to the store inventory.","type":"text/plain"},"url":{"path":["pet"],"host":["{{baseUrl}}"],"query":[],"variable":[]},"header":[{"disabled":false,"description":{"content":"The language you prefer for messages. Supported values are en-AU, en-CA, en-GB, en-US","type":"text/plain"},"key":"Accept-Language","value":""},{"key":"Content-Type","value":"application/json"}],"method":"POST","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}},"auth":{"type":"oauth2","oauth2":[]}}}
api: {"tags":["Pets"],"description":"Add new pet to the store inventory.","operationId":"addPet","responses":{"405":{"description":"Invalid input"}},"security":[{"petstore_auth":["write:pets","read:pets"]}],"x-codeSamples":[{"lang":"C#","source":"PetStore.v1.Pet pet = new PetStore.v1.Pet();\npet.setApiKey(\"your api key\");\npet.petType = PetStore.v1.Pet.TYPE_DOG;\npet.name = \"Rex\";\n// set other fields\nPetStoreResponse response = pet.create();\nif (response.statusCode == HttpStatusCode.Created)\n{\n // Successfully created\n}\nelse\n{\n // Something wrong -- check response for errors\n Console.WriteLine(response.getRawResponse());\n}\n"},{"lang":"PHP","source":"$form = new \\PetStore\\Entities\\Pet();\n$form->setPetType(\"Dog\");\n$form->setName(\"Rex\");\n// set other fields\ntry {\n $pet = $client->pets()->create($form);\n} catch (UnprocessableEntityException $e) {\n var_dump($e->getErrors());\n}\n"}],"requestBody":{"content":{"application/json":{"schema":{"allOf":[{"description":"My Pet","title":"Pettie"},{"type":"object","required":["name","photoUrls"],"discriminator":{"propertyName":"petType","mapping":{"cat":"#/components/schemas/Cat","dog":"#/components/schemas/Dog","bee":"#/components/schemas/HoneyBee"}},"properties":{"id":{"externalDocs":{"description":"Find more info here","url":"https://example.com"},"description":"Pet ID","allOf":[{"type":"integer","format":"int64","readOnly":true}]},"category":{"description":"Categories this pet belongs to","allOf":[{"type":"object","properties":{"id":{"description":"Category ID","allOf":[{"type":"integer","format":"int64","readOnly":true}]},"name":{"description":"Category name","type":"string","minLength":1},"sub":{"description":"Test Sub Category","type":"object","properties":{"prop1":{"type":"string","description":"Dumb Property"}}}},"xml":{"name":"Category"}}]},"name":{"description":"The name given to a pet","type":"string","example":"Guru"},"photoUrls":{"description":"The list of URL to a cute photos featuring pet","type":"array","maxItems":20,"xml":{"name":"photoUrl","wrapped":true},"items":{"type":"string","format":"url"}},"friend":{"allOf":[{"$ref":"#/components/schemas/Pet"}]},"tags":{"description":"Tags attached to the pet","type":"array","minItems":1,"xml":{"name":"tag","wrapped":true},"items":{"type":"object","properties":{"id":{"description":"Tag ID","allOf":[{"type":"integer","format":"int64","readOnly":true}]},"name":{"description":"Tag name","type":"string","minLength":1}},"xml":{"name":"Tag"}}},"status":{"type":"string","description":"Pet status in the store","enum":["available","pending","sold"]},"petType":{"description":"Type of a pet","type":"string"}},"xml":{"name":"Pet"}}]}},"application/xml":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"hooray"}}}}},"description":"Pet object that needs to be added to the store","required":true},"method":"post","path":"/pet","servers":[{"url":"https://petstore.swagger.io/v2","description":"Default server"},{"url":"https://petstore.swagger.io/sandbox","description":"Sandbox server"}],"securitySchemes":{"petstore_auth":{"description":"Get access to data while protecting your account credentials.\nOAuth2 is also a safer and more secure way to give you access.\n","type":"oauth2","flows":{"implicit":{"authorizationUrl":"http://petstore.swagger.io/api/oauth/dialog","scopes":{"write:pets":"modify pets in your account","read:pets":"read your pets"}}}},"api_key":{"description":"For this sample, you can use the api key `special-key` to test the authorization filters.\n","type":"apiKey","name":"api_key","in":"header"}},"jsonRequestBodyExample":{"id":{},"category":{"id":{},"name":"string","sub":{"prop1":"string"}},"name":"Guru","photoUrls":["string"],"friend":{},"tags":[{"id":{},"name":"string"}],"status":"available","petType":"string"},"info":{"description":"This is a sample server Petstore server.\nYou can find out more about Swagger at\n[http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\nFor this sample, you can use the api key `special-key` to test the authorization filters.\n\n## Introduction\nThis API is documented in **OpenAPI format** and is based on\n[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.\nIt was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)\ntool and [ReDoc](https://github.com/Redocly/redoc) documentation. In addition to standard\nOpenAPI syntax we use a few [vendor extensions](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md).\n\n## OpenAPI Specification\nThis API is documented in **OpenAPI format** and is based on\n[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.\nIt was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)\ntool and [ReDoc](https://github.com/Redocly/redoc) documentation. In addition to standard\nOpenAPI syntax we use a few [vendor extensions](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md).\n\n## Cross-Origin Resource Sharing\nThis API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/).\nAnd that allows cross-domain communication from the browser.\nAll responses have a wildcard same-origin which makes them completely public and accessible to everyone, including any code on any site.\n\n## Authentication\n\nPetstore offers two forms of authentication:\n - API Key\n - OAuth2\nOAuth2 - an open protocol to allow secure authorization in a simple\nand standard method from web, mobile and desktop applications.\n","version":"2.0.0","title":"Swagger Petstore YAML","termsOfService":"http://swagger.io/terms/","contact":{"name":"API Support","email":"apiteam@swagger.io","url":"https://github.com/Redocly/redoc"},"x-logo":{"url":"https://redocly.github.io/redoc/petstore-logo.png","altText":"Petstore logo"},"license":{"name":"Apache 2.0","url":"http://www.apache.org/licenses/LICENSE-2.0.html"}},"postman":{"name":"Add a new pet to the store","description":{"content":"Add new pet to the store inventory.","type":"text/plain"},"url":{"path":["pet"],"host":["{{baseUrl}}"],"query":[],"variable":[]},"header":[{"disabled":false,"description":{"content":"The language you prefer for messages. Supported values are en-AU, en-CA, en-GB, en-US","type":"text/plain"},"key":"Accept-Language","value":""},{"key":"Content-Type","value":"application/json"}],"method":"POST","body":{"mode":"raw","raw":"\"\"","options":{"raw":{"language":"json"}}},"auth":{"type":"oauth2","oauth2":[]}}}
sidebar_class_name: "post api-method"
info_path: petstore/swagger-petstore-yaml
---
Expand Down
Loading